<?php
require_once "weixin_info.php";
require_once "config.php";
$sale_sql = $mysql->query('select * from dyspw_salesman where u_id = '.$_SESSION['Member_info'][0]['id']);
$sale = $sale_sql->fetch_all(MYSQLI_ASSOC);
if(empty($sale)){
    $result['status'] = 'n';
    $result['info'] = '未查询到';
    exit(json_encode($result,JSON_UNESCAPED_UNICODE));
}else if($sale[0]['state'] != 1){
    $result['status'] = 'n';
    $result['info'] = '暂未通过审核';
    exit(json_encode($result,JSON_UNESCAPED_UNICODE));
}
$extract_sql = $mysql->query('select * from dyspw_salesman_extract where s_id = '.$sale[0]['id']);
$extract = $extract_sql->fetch_all(MYSQLI_ASSOC);
//print_r($extract);
$cash_sql = $mysql->query('select * from dyspw_sale_cash where s_id = '.$sale[0]['id']);
$cash = $cash_sql->fetch_all(MYSQLI_ASSOC);
$son_sql = $mysql->query('select * from dyspw_salesman where parent_id = '.$sale[0]['id']);
$son = $son_sql->fetch_all(MYSQLI_ASSOC);
// print_r($son);exit;
 ?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>业务员中心</title>
    <script src="js/mui.min.js"></script>
    <link rel="stylesheet" href="css/core.css">
    <link href="css/mui.min.css" rel="stylesheet" />
    <link href="css/personalCenter.css" rel="stylesheet" />
     <link rel="stylesheet" type="text/css" href="css/salesman_up.css">
    <style media="screen">
        section{    width: auto !important;}
    </style>
</head>
<?php if($result['status'] == 'n'){?>
    <body>
        <div id="content" class="statusMain">
            <div class="status">
                <p class="statusImg"><img src="images/sale_state0.png" alt=""></p>
                <!-- <div class="statusImg">
                    <div class="circle-border">
                        <div class="circle-core"></div>
                    </div>
                </div> -->
                <p class="statusText"><?php echo $result['info']; ?></p>
                <p class="promptText"><span class="promptImg"><img src="images/state_tishi.png" alt=""></span>正在跳转至5拍8用户中心<span class="time">3</span>s</p>
            </div>
        </div>
        <script src="js/jquery-2.2.4.min.js" type="text/javascript"></script>
    </body>
    <script type="text/javascript">
    $(function () {
        //演示跳转个人中心
        var i=3;
        after();
        function after(){
            $(".time").empty().append(i);
            i=i-1;
            setTimeout(function(){
                after();
            },1000);
        }
        setTimeout(function(){
            window.location.href='https://5p8.fyh5p8.com/xiaochengxu/member.php';
        },3000);//5秒后返回首页
    })
    </script>
<?php  }else{?>


<body>
    <article>
        <header class="header">
            <img class="avatar" src="<?php echo $sale[0]['u_avatar'] ?>" alt="">
            <p class="name"><?php echo $sale[0]['u_name'] ?></p>
            <p class="txt"><?php echo $sale[0]['u_intro'] ?></p>
            <div class="btnFlex">
                <!-- <p class="tagP">超级领队</p> -->
                <p class="saoyisao" style="padding-left:0px;padding: 0px 5px;width: auto;"><a href="sale_invite.php?type=shop" style="width: 100%;display: inline-block;text-align: center;color: #fff;"><span>邀请商户入驻</span> </a></p>
                <p class="saoyisao" style="padding-left:0px;padding: 0px 5px;width: auto;"><a href="sale_invite.php" style="width: 100%;display: inline-block;text-align: center;color: #fff;"><span>邀请业务员入驻</span> </a></p>
            </div>
            <!-- <p class="invitedCode"><a href="sale_invite.php">邀请码：<span><?php echo $sale[0]['invite_code'] ?></a></span></p> -->
        </header>
        <section class="incomeSec">
            <ul class="incomeUL">
                <li>
                    <p class="incomeTxt">可领取现金</p>
                    <p class="incomeNumber"><?php echo $sale[0]['cash']; ?></p>
                </li>

                <li>
                    <p class="incomeTxt">预计收入</p>
                    <p class="incomeNumber"><?php echo $sale[0]['expect_cash']; ?></p>
                </li>
            </ul>
            <div class="incomeDiv">
                <img src="./images/vision.png" alt="">
                <span class="hideMOney">隐藏金额</span>
                <!-- <p class="withdraw"><a href="cash_add.php" style="color:#fff;">立即提现</a></p> -->
            </div>
        </section>
        <section class="postionTop" style="margin-bottom: 60px;">
            <section class="partI">
                <p class="incomeRemark">
                    <span class="incomeRemarkNum">提现记录</span>
                    <!-- <span class="moreSpan">更多></span> -->
                </p>
                <ul>
                    <?php if(!empty($extract)){ ?>
                        <?php foreach ($extract as $key => $val) { ?>
                            <li class="contentI">
                                <p class="typeName"><span><?php echo$val['s_name']; ?></span><span class="storeName"><?php echo $val['info']; ?></span> </p>
                                <p class="timeP"><?php echo date('Y-m-d H:i:s', $val['launch_time']); ?></p>
                                <span class="moneySpan" style="top:70%;"> <?php echo $val['money']; ?> <em>元</em></span>
                                <span style="position: absolute;font-size: 12px;font-family: PingFang SC;font-weight: bold;color: #9a9a9a;right: 5px;top: 20%;">
                                    状态： <?php if($val['status'] == 1){echo "<em style='color:#4cd964;'>已通过</em>";}elseif ($val['status'] == '2') {echo "<em style='color:red;'>未通过</em>"; }else{echo "<em>审核中</em>";} ?>
                                </span>
                            </li>
                        <?php } ?>
                    <?php }else { ?>
                        <li style="text-align:center;font-size: 12px;color: #4c4c4c;">暂未提现记录</li>
                    <?php } ?>
                </ul>
            </section>
            <section class="partI">
                <p class="incomeRemark">
                    <span class="incomeRemarkNum">收入记录</span>
                    <!-- <span class="moreSpan">更多></span> -->
                </p>
                <ul>
                    <?php if(!empty($cash)){ ?>
                        <?php foreach ($cash as $key => $val) { ?>
                            <li class="contentI">
                                <p class="typeName"><span><?php echo $sale[0]['u_name']; ?></span><span class="storeName"><?php echo $val['info']; ?></span> </p>
                                <p class="timeP"><?php echo date('Y-m-d H:i:s', $val['time']); ?></p>
                                <span class="moneySpan"><?php echo $val['s_money']; ?> <em>元</em></span>
                            </li>
                        <?php } ?>
                    <?php }else{ ?>
                        <li style="text-align:center;font-size: 12px;color: #4c4c4c;">暂未收入记录</li>
                    <?php } ?>
                </ul>
            </section>


            <section class="partII">
<!--                <p class="incomeRemark">-->
<!--                    <span class="incomeRemarkNum">新手必读</span>-->
<!--                    <span class="middleSpan">帮新手小白了解5拍8招募系统</span>-->
<!--                </p>-->
                <div class="newerP">
                    <p class="newerTxt">让你的碎片时间变成金钱！</p>
                    <p class="newrDesc">5拍8帮你实现这个梦想</p>
                    <span class="aboutMore">了解更多></span>
                </div>
            </section>

            <section class="partIII">
                <p class="incomeRemark">
                    <span class="incomeRemarkNum">团队管理</span>
                </p>

                <table class="tableDiv">
                    <tr class="thTr">
                        <th>编号</th>
                        <th>名称</th>
                        <th>招商数量</th>
                        <th>收益</th>
                        <th>操作</th>
                    </tr>
                    <tr class="whiteTr"></tr>
                    <?php if(!empty($son)){ ?>
                        <?php foreach ($son as $key => $val) { ?>
                            <tr class="dataTr">
                                <td><?php echo $val['id']; ?></td>
                                <td><?php echo $val['u_name'] ?></td>
                                <td><?php echo $val['invite_num'] ?></td>
                                <td><?php echo $val['cash'] ?></td>
                                <td>
                                    <p class="checkInfo"><a href="member.php?id=<?php echo $val['u_id']; ?>" style="color: #fff;">查看</a></p>
                                </td>
                            </tr>
                        <?php } ?>
                    <?php }else{ ?>
                        <tr class="dataTr"><td colspan="5">暂未团队用户</td></tr>
                    <?php } ?>




                </table>
            </section>
        </section>

    </article>
    <footer style="background-color:#FFF;">
        <ul class="cl">
            <li><a href="index.php">首页</a></li>
            <li><a href="fenlei.php">分类</a></li>
            <li><a href="baishe.php">拍</a></li>
            <li><a href="shopping.php">商城</a></li>
            <li><a href="member.php">我</a></li>
        </ul>
    </footer>
    <script src="./js/jquery-2.2.4.min.js"></script>
    <script>

    </script>
</body>
<?php  } ?>
</html>
